<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2017/12/31
 * Time: 20:39
 */

namespace app\api\controller\v1;

use app\api\validate\IDMustBePostiveInt;
use app\api\model\Banner as BannerModel;
use app\lib\exception\BannerMissException;
use think\Exception;

class Banner
{
    /**
     * 获取指定id的banner信息
     * @$id banner的id号 正整数
     *
     * @http GET
     * @url  /banner/:id
     * http://z.cn/api/v1/banner/1?XDEBUG_SESSION_START=14416
     */
    public function getBanner($id)
    {
        (new IDMustBePostiveInt())->goCheck();

        $banner = BannerModel::getBannerByID($id);

        if(!$banner) {
            throw new BannerMissException();
        }

        return $banner;
    }
}